using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;

using FreeFlow.Administration;

namespace FreeFlowAdministrator
{
	/// <summary>
	/// Summary description for StageControl.
	/// </summary>
	public class StageControl : System.Windows.Forms.UserControl
	{
    private System.Windows.Forms.Label label1;
    private System.Windows.Forms.TextBox nameLabel;
    private System.Windows.Forms.Label label2;
    private System.Windows.Forms.TextBox typeLabel;
    private System.Windows.Forms.Label label3;
    private System.Windows.Forms.TextBox toDoListLabel;
    private System.Windows.Forms.Label label4;
    private System.Windows.Forms.TextBox watchListLabel;
    private System.Windows.Forms.Label label5;
    private System.Windows.Forms.TextBox whenStartedTextBox;
    private System.Windows.Forms.Label label6;
    private System.Windows.Forms.TextBox whenCompletedTextBox;
    private System.Windows.Forms.Label label7;
    private System.Windows.Forms.Label priorityLabel;
    private System.Windows.Forms.Label label8;
    private System.Windows.Forms.ListBox folderPageListBox;
    private UIActionsControl uiActionsControl;
		/// <summary> 
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public StageControl()
		{
			// This call is required by the Windows.Forms Form Designer.
			InitializeComponent();

      UIActionList actionList = new UIActionList();
      actionList.Add("Refresh", "Refresh the list", new ActionExecuteDelegate(RefreshStage));
      uiActionsControl.Actions = actionList;
		}

		/// <summary> 
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Component Designer generated code
		/// <summary> 
		/// Required method for Designer support - do not modify 
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
      this.label1 = new System.Windows.Forms.Label();
      this.nameLabel = new System.Windows.Forms.TextBox();
      this.label2 = new System.Windows.Forms.Label();
      this.typeLabel = new System.Windows.Forms.TextBox();
      this.label3 = new System.Windows.Forms.Label();
      this.toDoListLabel = new System.Windows.Forms.TextBox();
      this.label4 = new System.Windows.Forms.Label();
      this.watchListLabel = new System.Windows.Forms.TextBox();
      this.label5 = new System.Windows.Forms.Label();
      this.whenStartedTextBox = new System.Windows.Forms.TextBox();
      this.label6 = new System.Windows.Forms.Label();
      this.whenCompletedTextBox = new System.Windows.Forms.TextBox();
      this.label7 = new System.Windows.Forms.Label();
      this.priorityLabel = new System.Windows.Forms.Label();
      this.label8 = new System.Windows.Forms.Label();
      this.folderPageListBox = new System.Windows.Forms.ListBox();
      this.uiActionsControl = new FreeFlowAdministrator.UIActionsControl();
      this.SuspendLayout();
      // 
      // label1
      // 
      this.label1.Location = new System.Drawing.Point(8, 8);
      this.label1.Name = "label1";
      this.label1.Size = new System.Drawing.Size(40, 16);
      this.label1.TabIndex = 0;
      this.label1.Text = "Name:";
      // 
      // nameLabel
      // 
      this.nameLabel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                  | System.Windows.Forms.AnchorStyles.Right)));
      this.nameLabel.BorderStyle = System.Windows.Forms.BorderStyle.None;
      this.nameLabel.Location = new System.Drawing.Point(104, 8);
      this.nameLabel.Name = "nameLabel";
      this.nameLabel.ReadOnly = true;
      this.nameLabel.Size = new System.Drawing.Size(467, 13);
      this.nameLabel.TabIndex = 1;
      this.nameLabel.Text = "nameLabel";
      // 
      // label2
      // 
      this.label2.Location = new System.Drawing.Point(8, 24);
      this.label2.Name = "label2";
      this.label2.Size = new System.Drawing.Size(32, 16);
      this.label2.TabIndex = 2;
      this.label2.Text = "Type:";
      // 
      // typeLabel
      // 
      this.typeLabel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                  | System.Windows.Forms.AnchorStyles.Right)));
      this.typeLabel.BorderStyle = System.Windows.Forms.BorderStyle.None;
      this.typeLabel.Location = new System.Drawing.Point(104, 24);
      this.typeLabel.Name = "typeLabel";
      this.typeLabel.ReadOnly = true;
      this.typeLabel.Size = new System.Drawing.Size(467, 13);
      this.typeLabel.TabIndex = 3;
      this.typeLabel.Text = "typeLabel";
      // 
      // label3
      // 
      this.label3.Location = new System.Drawing.Point(8, 40);
      this.label3.Name = "label3";
      this.label3.Size = new System.Drawing.Size(56, 16);
      this.label3.TabIndex = 4;
      this.label3.Text = "To Do list:";
      // 
      // toDoListLabel
      // 
      this.toDoListLabel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                  | System.Windows.Forms.AnchorStyles.Right)));
      this.toDoListLabel.BorderStyle = System.Windows.Forms.BorderStyle.None;
      this.toDoListLabel.Location = new System.Drawing.Point(104, 40);
      this.toDoListLabel.Name = "toDoListLabel";
      this.toDoListLabel.ReadOnly = true;
      this.toDoListLabel.Size = new System.Drawing.Size(467, 13);
      this.toDoListLabel.TabIndex = 5;
      this.toDoListLabel.Text = "toDoListLabel";
      // 
      // label4
      // 
      this.label4.Location = new System.Drawing.Point(8, 56);
      this.label4.Name = "label4";
      this.label4.Size = new System.Drawing.Size(56, 16);
      this.label4.TabIndex = 6;
      this.label4.Text = "Watch list:";
      // 
      // watchListLabel
      // 
      this.watchListLabel.BorderStyle = System.Windows.Forms.BorderStyle.None;
      this.watchListLabel.Location = new System.Drawing.Point(104, 56);
      this.watchListLabel.Name = "watchListLabel";
      this.watchListLabel.ReadOnly = true;
      this.watchListLabel.Size = new System.Drawing.Size(512, 13);
      this.watchListLabel.TabIndex = 7;
      this.watchListLabel.Text = "watchListLabel";
      // 
      // label5
      // 
      this.label5.Location = new System.Drawing.Point(8, 72);
      this.label5.Name = "label5";
      this.label5.Size = new System.Drawing.Size(80, 16);
      this.label5.TabIndex = 8;
      this.label5.Text = "When started:";
      // 
      // whenStartedTextBox
      // 
      this.whenStartedTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                  | System.Windows.Forms.AnchorStyles.Right)));
      this.whenStartedTextBox.Location = new System.Drawing.Point(104, 72);
      this.whenStartedTextBox.Multiline = true;
      this.whenStartedTextBox.Name = "whenStartedTextBox";
      this.whenStartedTextBox.ReadOnly = true;
      this.whenStartedTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
      this.whenStartedTextBox.Size = new System.Drawing.Size(319, 80);
      this.whenStartedTextBox.TabIndex = 9;
      this.whenStartedTextBox.Text = "whenStartedTextBox";
      // 
      // label6
      // 
      this.label6.Location = new System.Drawing.Point(8, 160);
      this.label6.Name = "label6";
      this.label6.Size = new System.Drawing.Size(96, 16);
      this.label6.TabIndex = 10;
      this.label6.Text = "When completed:";
      // 
      // whenCompletedTextBox
      // 
      this.whenCompletedTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
                  | System.Windows.Forms.AnchorStyles.Right)));
      this.whenCompletedTextBox.Location = new System.Drawing.Point(104, 160);
      this.whenCompletedTextBox.Multiline = true;
      this.whenCompletedTextBox.Name = "whenCompletedTextBox";
      this.whenCompletedTextBox.ReadOnly = true;
      this.whenCompletedTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
      this.whenCompletedTextBox.Size = new System.Drawing.Size(319, 80);
      this.whenCompletedTextBox.TabIndex = 11;
      this.whenCompletedTextBox.Text = "whenCompletedTextBox";
      // 
      // label7
      // 
      this.label7.Location = new System.Drawing.Point(8, 248);
      this.label7.Name = "label7";
      this.label7.Size = new System.Drawing.Size(56, 16);
      this.label7.TabIndex = 12;
      this.label7.Text = "Priority:";
      // 
      // priorityLabel
      // 
      this.priorityLabel.Location = new System.Drawing.Point(104, 248);
      this.priorityLabel.Name = "priorityLabel";
      this.priorityLabel.Size = new System.Drawing.Size(100, 16);
      this.priorityLabel.TabIndex = 13;
      this.priorityLabel.Text = "priorityLabel";
      // 
      // label8
      // 
      this.label8.Location = new System.Drawing.Point(8, 264);
      this.label8.Name = "label8";
      this.label8.Size = new System.Drawing.Size(80, 16);
      this.label8.TabIndex = 14;
      this.label8.Text = "Folder pages:";
      // 
      // folderPageListBox
      // 
      this.folderPageListBox.BackColor = System.Drawing.SystemColors.Control;
      this.folderPageListBox.Location = new System.Drawing.Point(104, 264);
      this.folderPageListBox.Name = "folderPageListBox";
      this.folderPageListBox.Size = new System.Drawing.Size(216, 95);
      this.folderPageListBox.TabIndex = 15;
      // 
      // uiActionsControl
      // 
      this.uiActionsControl.Actions = null;
      this.uiActionsControl.Dock = System.Windows.Forms.DockStyle.Right;
      this.uiActionsControl.Location = new System.Drawing.Point(429, 0);
      this.uiActionsControl.Name = "uiActionsControl";
      this.uiActionsControl.Size = new System.Drawing.Size(150, 384);
      this.uiActionsControl.TabIndex = 16;
      // 
      // StageControl
      // 
      this.Controls.Add(this.uiActionsControl);
      this.Controls.Add(this.folderPageListBox);
      this.Controls.Add(this.label8);
      this.Controls.Add(this.priorityLabel);
      this.Controls.Add(this.label7);
      this.Controls.Add(this.whenCompletedTextBox);
      this.Controls.Add(this.label6);
      this.Controls.Add(this.whenStartedTextBox);
      this.Controls.Add(this.label5);
      this.Controls.Add(this.watchListLabel);
      this.Controls.Add(this.label4);
      this.Controls.Add(this.toDoListLabel);
      this.Controls.Add(this.label3);
      this.Controls.Add(this.typeLabel);
      this.Controls.Add(this.label2);
      this.Controls.Add(this.nameLabel);
      this.Controls.Add(this.label1);
      this.Name = "StageControl";
      this.Size = new System.Drawing.Size(579, 384);
      this.ResumeLayout(false);
      this.PerformLayout();

    }
		#endregion

    private Stage stage;
    public void LoadStage(Stage stage)
    {
      this.stage = stage;
      nameLabel.Text = stage.Name;
      typeLabel.Text = stage.StageType.ToString();
      toDoListLabel.Text = stage.ToDoList;
      watchListLabel.Text = stage.WatchList;
      whenStartedTextBox.Text = stage.WhenStarted;
      whenCompletedTextBox.Text = stage.WhenCompleted;
      priorityLabel.Text = stage.Priority.ToString();

      folderPageListBox.Items.Clear();
      for (int i = 0; i < stage.FolderPageCount; i++)
      {
        folderPageListBox.Items.Add(stage.FolderPage(i));
      }
    }

    private string RefreshStage()
    {
      stage.Refresh();
      LoadStage(stage);
      return null;
    }
	}
}
